﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:core="clr-namespace:System.Windows.Controls;assembly=Core">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/myManga;component/Themes/CoreResourceDictionary.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type RepeatButton}" x:Key="BrightnessControlRepeatButton">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border Background="Transparent" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Thumb}" x:Key="BrightnessControlThumb">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Height" Value="25"/>
        <Setter Property="Width" Value="25"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border 
                        x:Name="ThumbBorder"
                        BorderThickness="3"
                        BorderBrush="{DynamicResource window-foreground-disabled}"
                        Background="{DynamicResource window-foreground-disabled}">
                        <TextBlock
                            x:Name="ThumbIcon"
                            FontFamily="{DynamicResource OpenIconic}" 
                            Text="{DynamicResource oi-lightbulb}" 
                            Foreground="{DynamicResource window-theme-primary}"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Margin="0,-3,0,0"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="ThumbBorder" Property="Background" Value="{DynamicResource window-foreground-disabled}"/>
                            <Setter TargetName="ThumbBorder" Property="BorderBrush" Value="{DynamicResource window-theme-primary}"/>
                            <Setter TargetName="ThumbIcon" Property="Foreground" Value="{DynamicResource window-theme-primary}"/>
                        </Trigger>
                        <Trigger Property="IsDragging" Value="True">
                            <Setter TargetName="ThumbBorder" Property="Background" Value="{DynamicResource window-theme-primary}"/>
                            <Setter TargetName="ThumbBorder" Property="BorderBrush" Value="{DynamicResource window-theme-secondary}"/>
                            <Setter TargetName="ThumbIcon" Property="Foreground" Value="{DynamicResource window-theme-secondary}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="ThumbBorder" Property="Background" Value="{DynamicResource window-foreground-disabled}"/>
                            <Setter TargetName="ThumbBorder" Property="BorderBrush" Value="{DynamicResource window-foreground-disabled}"/>
                            <Setter TargetName="ThumbIcon" Property="Foreground" Value="{DynamicResource window-foreground-disabled}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="HorizontalSlider" TargetType="{x:Type Slider}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Border
                x:Name="TrackBorder"
                Margin="0"
                Grid.Row="1"
                Background="{DynamicResource window-theme-secondary}">
                <Track 
                    Grid.Row="1" 
                    x:Name="PART_Track">
                    <Track.DecreaseRepeatButton>
                        <RepeatButton Style="{StaticResource BrightnessControlRepeatButton}" Command="Slider.DecreaseLarge"/>
                    </Track.DecreaseRepeatButton>
                    <Track.Thumb>
                        <Thumb Style="{StaticResource BrightnessControlThumb}"/>
                    </Track.Thumb>
                    <Track.IncreaseRepeatButton>
                        <RepeatButton Style="{StaticResource BrightnessControlRepeatButton}" Command="Slider.IncreaseLarge"/>
                    </Track.IncreaseRepeatButton>
                </Track>
            </Border>
            <TickBar
                x:Name="TopTick"
                SnapsToDevicePixels="True"
                Placement="Top"
                Height="4"
                Visibility="Collapsed"
                Fill="{DynamicResource window-theme-primary}"/>
            <TickBar
                x:Name="BottomTick"
                Grid.Row="2"
                SnapsToDevicePixels="True"
                Placement="Bottom"
                Height="4"
                Visibility="Collapsed"
                Fill="{DynamicResource window-theme-primary}"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="TickPlacement" Value="Both">
                <Setter TargetName="TopTick" Property="Visibility" Value="Visible" />
                <Setter TargetName="BottomTick" Property="Visibility" Value="Visible" />
            </Trigger>
            <Trigger Property="TickPlacement" Value="TopLeft">
                <Setter TargetName="TopTick" Property="Visibility" Value="Visible" />
            </Trigger>
            <Trigger Property="TickPlacement" Value="BottomRight">
                <Setter TargetName="BottomTick" Property="Visibility" Value="Visible" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="VerticalSlider" TargetType="{x:Type Slider}">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Border
                x:Name="TrackBorder"
                Margin="0"
                Grid.Column="1"
                Background="{DynamicResource window-theme-secondary}">
                <Track 
                    Grid.Column="1" 
                    x:Name="PART_Track">
                    <Track.DecreaseRepeatButton>
                        <RepeatButton Style="{StaticResource BrightnessControlRepeatButton}" Command="Slider.DecreaseLarge"/>
                    </Track.DecreaseRepeatButton>
                    <Track.Thumb>
                        <Thumb Style="{StaticResource BrightnessControlThumb}"/>
                    </Track.Thumb>
                    <Track.IncreaseRepeatButton>
                        <RepeatButton Style="{StaticResource BrightnessControlRepeatButton}" Command="Slider.IncreaseLarge"/>
                    </Track.IncreaseRepeatButton>
                </Track>
            </Border>
            <TickBar
                x:Name="LeftTick"
                SnapsToDevicePixels="True"
                Placement="Left"
                Width="4"
                Visibility="Collapsed"
                Fill="{DynamicResource window-theme-primary}"/>
            <TickBar
                x:Name="RightTick"
                Grid.Column="2"
                SnapsToDevicePixels="True"
                Placement="Right"
                Width="4"
                Visibility="Collapsed"
                Fill="{DynamicResource window-theme-primary}"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="TickPlacement" Value="Both">
                <Setter TargetName="LeftTick" Property="Visibility" Value="Visible" />
                <Setter TargetName="RightTick" Property="Visibility" Value="Visible" />
            </Trigger>
            <Trigger Property="TickPlacement" Value="TopLeft">
                <Setter TargetName="LeftTick" Property="Visibility" Value="Visible" />
            </Trigger>
            <Trigger Property="TickPlacement" Value="BottomRight">
                <Setter TargetName="RightTick" Property="Visibility" Value="Visible" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style TargetType="{x:Type core:BrightnessControl}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Horizontal">
                <Setter Property="MinWidth" Value="15" />
                <Setter Property="Template" Value="{StaticResource HorizontalSlider}" />
            </Trigger>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="MinHeight" Value="15" />
                <Setter Property="Template" Value="{StaticResource VerticalSlider}" />
            </Trigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>